package com.qijian.quality.domain.report;

import com.qijian.common.utils.StringUtils;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class AccidentReport {
    private String checkDate;

    private Integer month;

    private BigDecimal money;

    private Integer severityCount;

    private Integer slightCount;


    public static AccidentReport init(String checkDate) {
        AccidentReport r = new AccidentReport();
        r.setMoney(BigDecimal.ZERO);
        r.setCheckDate(checkDate);
        r.setSeverityCount(0);
        r.setSlightCount(0);
        return r;
    }

    public void setCheckDate(String checkDate) {
        this.checkDate = checkDate;
        if (checkDate != null) {
            if (checkDate.length() == 7) {
                this.setMonth(Integer.valueOf(StringUtils.substringAfter(checkDate, '-')));
            }
        }
    }
}
